# 读取YAML文件
import yaml


class FastApiConfig:
    def __init__(self, port, swagger):
        self.port = port
        self.swagger = swagger

    def __str__(self):
        return f'FastApiConfig(port={self.port}, swagger={self.swagger})'
def load_yaml(file_path):
    with open(file_path, 'r') as file:
        return yaml.safe_load(file)


# 加载配置文件
config = load_yaml('application.yml')

print(f'返回数据类型：{type(config)}')
fastapi_dict = config["fast-api"]
fastapi_config = FastApiConfig(**fastapi_dict)
print(f'返回数据：{fastapi_config.port}')
print(f'返回数据：{config["mysql"]}')
